﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DeviceTest1
{
    public partial class SetFont : Form
    {
        public SetFont()
        {
            InitializeComponent();
        }


        Font  _setFontFa1;       
        
        string familyName = "";
        float fontSize=0.0f;

        string _setFontColor="";
       
        /// <summary>
        /// 设置字体
        /// </summary>
        public Font SetFontFa1
        {
            get
            {
                return _setFontFa1;
            }
            set
            {               
                _setFontFa1 = value;
            }
        }
       
        /// <summary>
        /// 设置字体颜色
        /// </summary>
        public string SetFontColor
        {
            get
            {
                return _setFontColor;
            }
            set
            {
                _setFontColor = value;
            }

        }    

        /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItem1_Click(object sender, EventArgs e)
        {
            
            if (comboBox1.SelectedItem.ToString() == "Tahoma")
            {               
                familyName = "Tahoma";
            }
            if (comboBox1.SelectedItem.ToString() == "Courier New")
            {
                familyName = "Courier New";
            }
            if (comboBox3.SelectedItem.ToString() == "黑色")
            {
                _setFontColor = "黑色";
            }
            if (comboBox3.SelectedItem.ToString() == "红色")
            {
                _setFontColor = "红色";
            }
            if (comboBox3.SelectedItem.ToString() == "绿色")
            {
                _setFontColor = "绿色";
            }

            fontSize = Convert.ToSingle(comboBox2.SelectedItem);
            _setFontFa1 = new Font(familyName,fontSize,FontStyle.Regular);

            MainForm mainForm = new MainForm();

            this.Hide();
            mainForm.Show();
            mainForm.textBox1.Font = _setFontFa1;

            if (comboBox3.SelectedItem.ToString() == "黑色")
            {
                mainForm.textBox1.ForeColor = Color.Black;
            }
            if (comboBox3.SelectedItem.ToString() == "红色")
            {
                mainForm.textBox1.ForeColor = Color.Red;
            }
            if (comboBox3.SelectedItem.ToString() == "绿色")
            {
                mainForm.textBox1.ForeColor = Color.Green;
            }

        }

        private void menuItem2_Click(object sender, EventArgs e)
        {
            MainForm mainForm = new MainForm();
            mainForm.Show();
            this.Close();
        }
    }
}